<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\Database\Model\SoftDeletes;
/**
 * @property int $id 节点ID
 * @property string $title 标题
 * @property string $name 标识,用于读取某分组下的轮播图
 * @property int $type 类型  1轮播2矩形横幅
 * @property string $description 描述
 * @property int $sort 排序
 * @property int $status 状态
 * @property string $remark 备注
 * @property \Carbon\Carbon $created_at 操作时间
 * @property \Carbon\Carbon $updated_at 更新时间
 * @property int $created_user 操作人
 * @property string $deleted_at 软删除
 */
class AdvertCate extends BaseModel
{
    use SoftDeletes;
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'advert_cates';
    protected $hidden = ['deleted_at'];
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['id', 'title', 'name', 'type', 'sort', 'status', 'remark', 'created_at', 'updated_at', 'created_user', 'deleted_at'];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'int', 'type' => 'integer', 'sort' => 'integer', 'status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'created_user' => 'integer'];
    /**
     * [advert 关联广告数据]
     * @return [type] [description]
     */
    public function advert()
    {
        return $this->hasMany(Advert::class, 'cate_id', 'id')->where('status', 1);
    }
    /**
     * [createuser 创建者]
     * @return [type] [description]
     */
    public function createuser()
    {
        return $this->hasOne(User::class, 'id', 'created_user');
    }
}